<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文件上传</title>
    <style>
        input {
            padding: 8px;
            margin-right: 10px;
        }

        button {
            padding: 8px 16px;
            cursor: pointer;
        }

        #result {
            margin-top: 10px;
        }
    </style>
</head>

<body>
    <input type="text" id="filePath" placeholder="请输入文件路径">
    <button onclick="uploadFile()">上传</button>
    <button onclick="clearFilePath()">清空</button>
    <div id="result"></div>

    <script>
        function uploadFile() {
            const filePath = document.getElementById('filePath').value;
            const resultDiv = document.getElementById('result');
            if (filePath === "") {
                resultDiv.innerHTML = "传入正确的文件地址";
            } else {
                const fileName = filePath.split('\\').pop() || filePath.split('/').pop();
                resultDiv.innerHTML = `上传成功，文件名：${fileName}`;
            }
        }

        function clearFilePath() {
            const filePathInput = document.getElementById('filePath');
            const resultDiv = document.getElementById('result');
            filePathInput.value = "";
            resultDiv.innerHTML = "";
        }
    </script>
</body>

</html>
